#include <iostream>
#include <forward_list>

int arr[]={3,6,9};

namespace YX
{
    template<typename T>
    struct Func
    {
        bool operator()(const T& x)
        {
            return x%2==0;
        }
    };
};

int main(int argc,char* argv[],char* env[])
{

    // 无参默认构造
    std::forward_list<int> first;
    // n个val
    std::forward_list<int> second(3,9);
    // 迭代区间构造
    std::forward_list<int> third(second.begin(),second.end());
    // 拷贝构造
    std::forward_list<int> fourth(second);
    // std::move
    // 列表初始化
    // std::forward_list<int> fifth{1,2,3,4,5,6};
    std::forward_list<int> fifth={1,2,3,4,5,6};

    std::cout<<*fifth.before_begin()<<std::endl;

    std::forward_list<int>::iterator it=fifth.begin();

    while(it!=fifth.end())
    {
        std::cout<<*it<<std::endl;
        it++;
    }
    std::cout<<std::endl;
    // insert_after的使用
    // iterator insert_after ( const_iterator position, const value_type& val  );
    //auto ret=fifth.insert_after(fifth.before_begin(),0);
    //iterator insert_after ( const_iterator position, size_type n, const value_type& val  );
    //auto ret=fifth.insert_after(fifth.before_begin(),3,0);
    //template <class InputIterator>  iterator insert_after ( const_iterator position, InputIterator first, InputIterator last  );
    //auto ret=fifth.insert_after(fifth.before_begin(),arr,arr+sizeof(arr)/sizeof(arr[0]));
    //
    //erase_after的使用
    //iterator erase_after (const_iterator position);
    //auto ret=fifth.erase_after(fifth.before_begin());
    
    // 结点转移
    // void splice_after (const_iterator position, forward_list& fwdlst);
    // void splice_after (const_iterator position, forward_list& fwdlst, const_iterator i);
    //fifth.splice_after(fifth.before_begin(),second);
    
    // remove 按值删除
    //fifth.remove(2);
    //template <class Predicate>  void remove_if (Predicate pred);---条件删除
    //fifth.remove_if(YX::Func<int>());

    //printf("ret:%d\n",*ret);

    // reverse元素逆置
    //fifth.reverse();
    // sort template <class Compare>  void sort (Compare comp);
    fifth.sort(std::greater<int>());

    // merge---有序归并或者无序归并
    fifth.merge(second,std::greater<int>());

    // unique 删除重复的值
    fifth.unique();

    it=fifth.begin();

    while(it!=fifth.end())
    {
        std::cout<<*it<<std::endl;
        it++;
    }
    std::cout<<std::endl;



    //for(auto e: second)
    //{
    //    std::cout<<e<<std::endl;
    //}

    //fifth.assign(second.begin(),second.end());
    //fifth.assign(3,9);

    //it=fifth.begin();

    //while(it!=fifth.end())
    //{
    //    std::cout<<*it<<std::endl;
    //    it++;
    //}
    //std::cout<<std::endl;

    //fifth.push_front(0);
    //
    //it=fifth.begin();

    //while(it!=fifth.end())
    //{
    //    std::cout<<*it<<std::endl;
    //    it++;
    //}
    //std::cout<<std::endl;

    //fifth.pop_front();
    //
    //it=fifth.begin();

    //while(it!=fifth.end())
    //{
    //    std::cout<<*it<<std::endl;
    //    it++;
    //}
    //std::cout<<std::endl;

    return 0;
}

